package com.fjw.controller;

import com.fjw.pojo.Cv;
import com.fjw.pojo.Result;
import com.fjw.service.CvService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cv")
public class CvController {

    @Autowired
    private CvService cvService;

    @PostMapping("/add")
    public Result add(@RequestBody Cv cv){
        System.out.println(cv);
        cvService.add(cv);
        return Result.success();
    }

    @GetMapping("/findById")
    public Result<Cv> findById(Integer id){
        System.out.println(id);
        Cv res = cvService.findById(id);
        return Result.success(res);
    }

    @GetMapping("/findByAuthor")
    public Result<List<Cv>> findByAuthor(Integer author){
        System.out.println(author);
        List<Cv> res = cvService.findByAuthor(author);
        return Result.success(res);
    }

    @GetMapping("/getAll")
    public Result<List<Cv>> getAll(){
        List<Cv> res = cvService.getAll();
        return Result.success(res);
    }

    @PatchMapping("/updateById")
    public Result updateById(@RequestBody Cv cv){
        System.out.println(cv);
        cvService.updateById(cv);
        return Result.success();
    }

//    @GetMapping("/getByIds")
//    public Result<List<Cv>> getByIds()
}
